extends Area2D

@export var color : String
var objects_count : int = 0

func _on_cbutton_toggled(button_enabled : bool):
	get_tree().call_group("button_listeners", "on_button_toggled", color, button_enabled)


func _on_body_entered(_body):
	if objects_count == 0:
		_on_cbutton_toggled(true)
	objects_count += 1


func _on_body_exited(_body):
	objects_count -= 1
	if objects_count == 0:
		_on_cbutton_toggled(false)
